<?php
include_once "xAP-functions/webincludes.php";
echo webpageheader();
?>

  <script>
  $(document).ready(function(){
    $("#channellist").sortable({});
  });
  function Save(){
	$v=$('#channellist').sortable('serialize');
	$(".buttonbar").hide();
	$("#channels").html("<img src='/images/throbber.gif'> Saving");
	$.post("config_order_save.php",$v,
	function(data){
		$("#channels").html(data);
		
	},"text");
  }
  </script>

<style>
.channels ul { list-style: none; cursor: hand; cursor: pointer;}
.channels li { background: #eee;color: #000; width: 500px; margin: 5px; font-size: 26px; font-family: Arial; padding: 3px; }
</style>

<?php

$now=date("Y-m-d H:i:s");


$sql="select ChannelName,ChannelAlias,ChannelIcon,ChannelID 
from xAP_TV_Channel 
order by xAP_TV_Channel.ChannelOrder
";
$results=dbquery($sql);

//display
echo "
<div class='buttonbar'><input type='button' value='Save Order' OnClick='Save()'></div>
<div class='channels' unselectable='on' id='channels' style='min-height: 110px; height: auto ! important; -moz-user-select: none;'><ul id='channellist'>";
foreach($results as $row){
	echo "<li id='id_".$row["ChannelID"]."'><img src='images/channels/".$row["ChannelName"].".jpg' height=25 width=33>".$row["ChannelAlias"]."</li>";
}
echo "</ul></div>";

echo webpagefooter();
?>